home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
BARNET
/
FREENET
/
MELL
/
NETLIB00
/
NetLib
/
c
/
readline
< prev
next >
Wrap
Text File
|
1995-01-10
|
637b
|
39 lines
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "socketlib.h"
/*
* Read a line from a file, junking comments
*/
char *__socketlib_readline(FILE *file)
{
static char line[256];
char *hash;
do
{
/* Read a line from the file */
if (fgets(line, 256, file) == NULL)
return NULL;
/* Format the line */
if ((hash = strchr(line, '#')) != NULL)
{
/* Throw away any comments on the line */
*hash = '\0';
}
else
{
/* Remove the newline */
line[strlen(line) - 1] = '\0';
}
}
while (strlen(line) == 0);
/* Return the line */
return line;
}